package com.pds.web.company.controller;

import com.pds.common.core.controller.BaseController;
import com.pds.common.core.domain.R;
import com.pds.common.core.page.TableDataInfo;
import com.pds.web.company.domain.PdsCompanyInfo;
import com.pds.web.company.domain.PdsCompanyVO;
import com.pds.web.company.service.IPdsCompanyVOService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/company")
public class PdsCompanyVOController extends BaseController {

    @Autowired
    private IPdsCompanyVOService pdsCompanyVOService;

    @GetMapping("/detailList")
    public TableDataInfo detailList(PdsCompanyInfo pdsCompanyInfo) {
        startPage();

        List<PdsCompanyVO> list = pdsCompanyVOService.detailList(pdsCompanyInfo);

        Long companyCount = pdsCompanyVOService.selectCompanyCount(pdsCompanyInfo);

        TableDataInfo dataTable = getDataTable(list);
        dataTable.setTotal(companyCount);

        return dataTable;
    }

    @GetMapping("/detail")
    public R<PdsCompanyVO> detail() {
        return R.ok(pdsCompanyVOService.detail());
    }

//    @GetMapping("/detailOld")
//    public R<PdsCompanyVO> detailOld(PdsCompanyInfo pdsCompanyInfo) {
//        Long deptId = SecurityUtils.getLoginUser().getUser().getDeptId();
//        pdsCompanyInfo.setDeptId(deptId);
//
//        List<PdsCompanyVO> list = pdsCompanyVOService.detailList(pdsCompanyInfo);
//        return R.ok(list.get(0));
//    }
}
